import { Component, OnInit, Input } from '@angular/core';
import { PlotService } from '../../plot.service';

@Component({
  selector: 'app-underground-water',
  templateUrl: './underground-water.component.html',
  styleUrls: ['./underground-water.component.scss']
})
export class UndergroundWaterComponent implements OnInit {
  @Input() selectedIndex = 1;
  sortOrder = null
  fixedColumn = true
  public menus = [
    {
      title: "IV类水质",// v3
      value: 'v3',
      active: false
    },
    {
      title: "V类水质", //v4
      value: 'v4',
      active: true
    }
  ]

  public start = 0
  public rows = 200
  public tableData = []

  public theight = 600

  constructor(
    private plotService: PlotService
  ) { }

  ngOnInit() {
    this.getData(this.start, this.rows, 'v4')
  }

  getData(start, rows, std) {
    this.plotService.getLandWater({
      start, rows, std
    }).subscribe((data: any) => {
      if (data && data.results) {
        this.tableData = data.results
      }
    })
  }

  selectedIndexChange(index) {
    let value = this.menus[index].value
    this.getData(this.start, this.rows, value)
  }

  // (a: DataItem, b: DataItem) => a.name.localeCompare(b.name),
  nzSortFnMult(a, b) {
    return a.mult - b.mult
  }

  nzSortFnVal(a, b) {
    return a.val - b.val
  }

}
